import type { FieldRule } from 'vant'
/**
 * 手机号校验规则
 */
const mobileRules: FieldRule[] = [
  { required: true, message: '请填写用户名' },
  { pattern: /^1[3-9]\d{9}$/, message: '手机号格式不正确' }
]
/**
 * 密码校验规则
 */
const PassRules: FieldRule[] = [
  { required: true, message: '请输入密码' },
  // [a-zA-Z0-9-_] = \w
  { pattern: /^\w{8,24}$/, message: '密码格式不正确' }
]
/**
 * 验证码校验规则
 */
const CodeRules: FieldRule[] = [
  { required: true, message: '请输入验证码' },
  { pattern: /^\d{6}$/, message: '验证码格式不正确' }
]

/**
 * 名字校验规则
 */
const NameRules: FieldRule[] = [
  { required: true, message: '请输入姓名' },
  { pattern: /^(?:[\u4e00-\u9fa5·]{2,16})$/, message: '姓名输入不正确' }
]

/**
 * 身份证校验规则
 */
const IdCardRules: FieldRule[] = [
  { required: true, message: '请输入身份证' },
  {
    pattern:
      /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/,
    message: '身份证输入不正确'
  }
]

export { mobileRules, PassRules, CodeRules, NameRules, IdCardRules }
